<template>
	<view class="homepage">
       <view class="topbanner" >
       	<view class="bannertitle">
       		<view class="iconfont icon-shuju-05">
       			
       		</view>
			用户总览
       	</view>
		<view class="topbannerlist">
			<view class="itembanner" @click="gouserteam(1)">
				<view class="bannernameline">
					<view class="yuan">
						<view class="iconfont icon-yisheng-02">
							
						</view>
					</view>
					<view class="bannername">
						主管用户
					</view>
				</view>
				<view class="num">
				{{homedata.type1||0}}
				</view>
				<view class="bannerlabel">
					管理患者数
				</view>
			</view>
			<view class="itembanner" @click="gouserteam(2)">
				<view class="bannernameline">
					<view class="yuan">
						<view class="iconfont icon-tuandui">
							
						</view>
					</view>
					<view class="bannername">
						协管用户
					</view>
				</view>
				<view class="num">
					{{homedata.type2||0}}
				</view>
				<view class="bannerlabel">
					团队成员数
				</view>
			</view>
			<view class="itembanner" @click="bannerdetail">
				<view class="bannernameline">
					<view class="yuan">
						<view class="iconfont icon-rili2">
							
						</view>
					</view>
					<view class="bannername">
						今日随访
					</view>
				</view>
				<view class="num">
					--/--
				</view>
				<view class="bannerlabel">
					刷一下几科标记完成
				</view>
			</view>
			<view class="itembanner" @click="bannerdetail">
				<view class="bannernameline">
					<view class="yuan">
						<view class="iconfont icon-rili2">
							
						</view>
					</view>
					<view class="bannername">
						本周随访
					</view>
				</view>
				<view class="num">
					0
				</view>
				<view class="bannerlabel">
					点击展开日视图
				</view>
			</view>
			<view class="itembanner" @click="gouser">
				<view class="bannernameline">
					<view class="yuan">
						<view class="iconfont icon-robot-2-fill">
							
						</view>
					</view>
					<view class="bannername">
						主动随访
					</view>
				</view>
				<view class="num">
					0
				</view>
				<view class="bannerlabel">
					AI生成待办清单
				</view>
			</view>
			<view class="itembanner" @click="gouser">
				<view class="bannernameline">
					<view class="yuan">
						<view class="iconfont icon-tixing-tianchong">
							
						</view>
					</view>
					<view class="bannername">
						关键行动
					</view>
				</view>
				<view class="num">
					0
				</view>
				<view class="bannerlabel">
					长按可snooze
				</view>
			</view>
		</view>
       </view>
	   
	   <view class="teambox">
	   	<view class="teamline" >
	   		<view class="bannertitle">
	   			<view class="iconfont icon-tuandui1">
	   				
	   			</view>
	   			我的邀请
	   		</view>
		<!-- 	<view class="teambtn" @click="bannerdetail">
				+创建团队
			</view> -->
	   	</view>
		<view class="teamlist">
			<view style="text-align: center;color: #cccccc;"  v-if="yaoqinglist.length==0">
				暂无数据
			</view>
			<view class="itemteam" v-for="item in yaoqinglist" :key="item.id">
				<view class="left">
				
					<view class="teamtitle">
						<!-- 邀请你成为<view class="use">李四</view>的  <view class="role">联席专家</view> -->
						{{item.aiContent}}
					</view>
				</view>
			     <view class="teaminfobox">
			     	<view class="jujue" @click="jujueyaoqing(item)">
			     		拒绝
			     	</view>
					<view class="tongyi" @click="tongyiyaoqing(item)">
						同意
					</view>
			     </view>
			</view>
			
		</view>
	   </view>
	   
	   <view class="teambox">
	   	<view class="teamline">
	   		<view class="bannertitle">
	   			<view class="iconfont icon-woshou">
	   				
	   			</view>
	   			联席团队
	   		</view>
	   			<view class="teammore" @click="bannerdetail">
	   				查看更多
	   			</view>
	   	</view>
	   		<view class="teamlist">
	   			<view class="itemteam">
	   				<view class="left">
	   					<view class="teamname">
	   						糖尿病逆转
	   					</view>
	   					<view class="teamtitle">
	   						这是简单的说明内容
	   					</view>
	   				</view>
	   				<view class="morebtn" @click="bannerdetail">
	   					查看详情
	   				</view>
	   			</view>
	   			
	   		</view>
	   </view>
	   
	   
		<view class="getbox">
			<view class="bannertitle">
				<view class="iconfont icon-jichutubiao-xinzengwendang">
					
				</view>
			     需求申请
			</view>
			
			<view class="getlist">
				<view class="itemlist" @click="hezuoshenqing">
					<view class="itemname">
						合作申请
					</view>
					<view class="content">
						会议、交流、商务合作等
					</view>
					<view class="iconfont icon-xindong1">
						
					</view>
				</view>
				<view class="itemlist" @click="fabushenqing">
					<view class="itemname">
						发布申请
					</view>
					<view class="content">
						通知、公告、活动患者招募等
					</view>
					<view class="iconfont icon-xindong1">
						
					</view>
				</view>
			</view>
		</view>
	

		
		
	
		
		
		<view class="foot-tabbar">
			<view class="itemfootbar">
				<image src="/static/tabbar/首页 (3).png" mode=""></image>
				<view class="tabbarname footact">
					首页
				</view>
			</view>
			<view class="itemfootbar" @click="goxueshu">
				<image src="/static/tabbar/学位帽.png" mode=""></image>
				<view class="tabbarname ">
					学术
				</view>
			</view>
			<view class="itemfootbar footbardata"  @click="gosuifang">
				<image src="/static/tabbar/first-aid-kit-line.png" mode=""></image>
				<view class="tabbarname ">
					随访
				</view>
			</view>
			<view class="itemfootbar" @click="gouser">
				<image src="/static/tabbar/团队.png" mode=""></image>
				<view class="tabbarname ">
				用户
				</view>
			</view>
			<view class="itemfootbar" @click="gocenter">
				<image src="/static/tabbar/我的.png" mode=""></image>
				<view class="tabbarname ">
					我的
				</view>
			</view>
			
		</view>
	</view>
</template>

<script>
	import {getInfo,doctorInvitation,doctorInvitationPassOrRefuse,doctorIndexData,buyService} from '../../utils/api.js'
	export default {
		data() {
			return {
				pro:{
					reviewerstatus:0
				},
				yaoqinglist:[],
				homedata:{}
			}
		},
		onLoad(e) {
			
			if(e.phone){
				uni.setStorageSync('tuiphone',e.phone)
			}

		},
		onShow() {
			if(uni.getStorageSync('tuiphone')){
				let a={
					phone:uni.getStorageSync('phone'),
					doctorPhone:uni.getStorageSync('tuiphone')
				}
				buyService(a).then(res=>{
					console.log(res)
					uni.clearStorageSync('tuiphone')
					let p={
									phone:uni.getStorageSync('phone')
								}
					getInfo(p).then(res=>{
								 if(res.data.code==200){
									  uni.setStorageSync('type',res.data.data.usertype)
									 		 			  console.log(res,'用户信息')
									 		 			  this.pro=res.data.data
									 		 			  uni.setStorageSync('user',res.data.data)
									 					  
									 					  doctorInvitation(p).then(res=>{
									 					  			  console.log(res,'我收到的邀请')
									 					  			  this.yaoqinglist=res.data.data
									 					  })
									 					  doctorIndexData(p).then(res=>{
									 					  			  console.log(res,'首页数据')
									 					  			  this.homedata=res.data.data
									 					  })
								 }
					})
				})
			}else{
				let p={
								phone:uni.getStorageSync('phone')
							}
				getInfo(p).then(res=>{
							 if(res.data.code==200){
								  uni.setStorageSync('type',res.data.data.usertype)
								 		 			  console.log(res,'用户信息')
								 		 			  this.pro=res.data.data
								 		 			  uni.setStorageSync('user',res.data.data)
								 					  
								 					  doctorInvitation(p).then(res=>{
								 					  			  console.log(res,'我收到的邀请')
								 					  			  this.yaoqinglist=res.data.data
								 					  })
								 					  doctorIndexData(p).then(res=>{
								 					  			  console.log(res,'首页数据')
								 					  			  this.homedata=res.data.data
								 					  })
							 }
				})
			}
			
		
		
		
			
		
		},
		methods: {
			hezuoshenqing(){
				console.log('111111')
				uni.previewImage({
							urls: ['https://changban.dianjingkeji.net/img/hezuo.png'],
							longPressActions: {
								itemList: ['发送给朋友', '保存图片', '收藏'],
								success: function(data) {
									console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
								},
								fail: function(err) {
									console.log(err.errMsg);
								}
							}
						});
			},
			fabushenqing(){
				uni.previewImage({
							urls: ['https://changban.dianjingkeji.net/img/fabu.png'],
							longPressActions: {
								itemList: ['发送给朋友', '保存图片', '收藏'],
								success: function(data) {
									console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
								},
								fail: function(err) {
									console.log(err.errMsg);
								}
							}
						});
			},
			
			jujueyaoqing(e){
				let that=this
				uni.showModal({
					title: '提示',
					content: '拒绝加入团队',
					success: function (res) {
						if (res.confirm) {
						let p={
							phone:uni.getStorageSync('phone'),
							aiStatus:2,
							id:e.id
						}
						doctorInvitationPassOrRefuse(p).then(res=>{
							console.log(res)
							if(res.data.code==200){
								uni.showToast({
									title: '已拒绝',
									icon:'none',
									duration: 2000
								});
								let a={
									phone:uni.getStorageSync('phone')
								}
								doctorInvitation(a).then(res=>{
											  console.log(res,'我收到的邀请')
											  that.yaoqinglist=res.data.data
								})

							}else{
								uni.showToast({
									title: res.data.msg,
									icon:'none',
									duration: 2000
								});
							}
						})
							console.log('用户点击确定');
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});

			},
			tongyiyaoqing(e){
				let that=this
				uni.showModal({
					title: '提示',
					content: '加入团队',
					success: function (res) {
						if (res.confirm) {
						let p={
							phone:uni.getStorageSync('phone'),
							aiStatus:1,
							id:e.id
						}
						doctorInvitationPassOrRefuse(p).then(res=>{
							console.log(res)
							if(res.data.code==200){
								uni.showToast({
									title: '已同意',
									icon:'none',
									duration: 2000
								});
								let a={
									phone:uni.getStorageSync('phone')
								}
								doctorInvitation(a).then(res=>{
											  console.log(res,'我收到的邀请')
											  that.yaoqinglist=res.data.data
								})
			
							}else{
								uni.showToast({
									title: res.data.msg,
									icon:'none',
									duration: 2000
								});
							}
						})
							console.log('用户点击确定');
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			
			},
			
			
			gouserteam(e){
				uni.redirectTo({
					url:'/pages/user/user?type='+e
				})
				// if(this.pro.reviewerstatus==0){
				// 	uni.showToast({
				// 		title: '医生资质认证审核中，暂无权限',
				// 		icon:'none',
				// 		duration: 2000
				// 	});
					
				// }else if(this.pro.reviewerstatus==1){
				// 	uni.redirectTo({
				// 		url:'/pages/user/user?type='+e
				// 	})
				// }else {
				// 	uni.showModal({
				// 		title: '未认证',
				// 		content: '去认证资料',
				// 		success: function (res) {
				// 			if (res.confirm) {
				// 				console.log('用户点击确定');
				// 				uni.navigateTo({
				// 					url:'/pagesA/adddoctor/adddoctor'
				// 				})
				// 			} else if (res.cancel) {
				// 				console.log('用户点击取消');
				// 			}
				// 		}
				// 	});
				// }
				
			},
		
			
			bannerdetail(e){
				uni.redirectTo({
					url:'/pages/user/user'
				})
				// if(this.pro.reviewerstatus==0){
				// 	uni.showToast({
				// 		title: '医生资质认证审核中，暂无权限',
				// 		icon:'none',
				// 		duration: 2000
				// 	});
					
				// }else if(this.pro.reviewerstatus==1){
				// 	uni.redirectTo({
				// 		url:'/pages/user/user'
				// 	})
				// }else {
				// 	uni.showModal({
				// 		title: '未认证',
				// 		content: '去认证资料',
				// 		success: function (res) {
				// 			if (res.confirm) {
				// 				console.log('用户点击确定');
				// 				uni.navigateTo({
				// 					url:'/pagesA/adddoctor/adddoctor'
				// 				})
				// 			} else if (res.cancel) {
				// 				console.log('用户点击取消');
				// 			}
				// 		}
				// 	});
				// }

			},
			goxueshu(){
				uni.redirectTo({
					url:'/pages/xueshu/xueshu'
				})
			},
			gocenter(){
				uni.redirectTo({
					url:'/pages/center/center'
				})
			},
			gouser(){
				uni.redirectTo({
					url:'/pages/user/user'
				})
				// if(this.pro.reviewerstatus==0){
				// 	uni.showToast({
				// 		title: '医生资质认证审核中，暂无权限',
				// 		icon:'none',
				// 		duration: 2000
				// 	});
					
				// }else if(this.pro.reviewerstatus==1){
				// 	uni.redirectTo({
				// 		url:'/pages/user/user'
				// 	})
				// }else {
				// 	uni.showModal({
				// 		title: '未认证',
				// 		content: '去认证资料',
				// 		success: function (res) {
				// 			if (res.confirm) {
				// 				console.log('用户点击确定');
				// 				uni.navigateTo({
				// 					url:'/pagesA/adddoctor/adddoctor'
				// 				})
				// 			} else if (res.cancel) {
				// 				console.log('用户点击取消');
				// 			}
				// 		}
				// 	});
				// }
			},
			gosuifang(){
				uni.redirectTo({
					url:'/pages/data/data'
				})
				// if(this.pro.reviewerstatus==0){
				// 	uni.showToast({
				// 		title: '医生资质认证审核中，暂无权限',
				// 		icon:'none',
				// 		duration: 2000
				// 	});
					
				// }else if(this.pro.reviewerstatus==1){
				// 	uni.redirectTo({
				// 		url:'/pages/data/data'
				// 	})
				// }else {
				// 	uni.showModal({
				// 		title: '未认证',
				// 		content: '去认证资料',
				// 		success: function (res) {
				// 			if (res.confirm) {
				// 				console.log('用户点击确定');
				// 				uni.navigateTo({
				// 					url:'/pagesA/adddoctor/adddoctor'
				// 				})
				// 			} else if (res.cancel) {
				// 				console.log('用户点击取消');
				// 			}
				// 		}
				// 	});
				// }
				
			},
			
		}
	}
</script>

<style lang="less" scoped>
	.homepage{
		width: 750rpx;
		box-sizing: border-box;
		padding-bottom: 250rpx;
		background-color: whitesmoke;
		
		.topbanner{
			width: 100%;
			
			
			.bannertitle{
				display: flex;
				align-items: center;
				background-color: white;
				padding: 20rpx 30rpx;
				font-size: 36rpx;
				font-weight: bold;
				color: #1a4f8a;
				.iconfont{
					font-size: 40rpx;
					color: #1a4f8a;
					font-weight: bold;
					margin-right: 20rpx;
				}
			}
			.topbannerlist{
				width: 100%;
				box-sizing: border-box;
				padding: 20rpx 30rpx;
				display: flex;
				align-items: flex-start;
				flex-wrap: wrap;
				.itembanner{
					width: 46%;
					margin: 2%;
					border-radius: 20rpx;
					background-color: white;
					border-top: 6rpx solid #1a4f8a;
					padding-bottom: 20rpx;
					 box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.3);
					.bannernameline{
						width: 92%;
						margin: auto;
						display: flex;
						align-items: center;
						justify-content: space-evenly;
						margin-top: 30rpx;
						.yuan{
							width: 100rpx;
							height: 100rpx;
							border-radius: 50%;
							line-height: 100rpx;
							text-align: center;
							background-color:#f1f5f8 ;
							.iconfont{
								font-size: 56rpx;
								
								
								color: #1a4f8a;
								margin: auto;
							}
						}
						.bannername{
							font-size: 34rpx;
							font-weight: bold;
						}
					}
					.num{
						line-height: 2;
						font-size: 62rpx;
						font-weight: bold;
						color: #1a4f8a;
						margin-left: 30rpx;
					}
					.bannerlabel{
						font-size: 30rpx;
						font-weight: bold;
						color: #5d5d5d;
						margin: 4rpx 0 40rpx 30rpx;
					}
				}
			}
			
		}
		
		.teambox{
			width: 100%;
			box-sizing: border-box;
			padding: 20rpx;
			.teamline{
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: space-between;
				.bannertitle{
					display: flex;
					align-items: center;
					
					padding: 20rpx 30rpx;
					font-size: 36rpx;
					font-weight: bold;
					color: #1a4f8a;
					.iconfont{
						font-size: 50rpx;
						color: #1a4f8a;
						font-weight: bold;
						margin-right: 20rpx;
					}
				}
		
				.teammore{
					color: #1a4f8a;
				}
				.teambtn{
					width: 200rpx;
					height: 80rpx;
					color: white;
					font-size: 30rpx;
					text-align: center;
					line-height: 80rpx;
					border-radius: 20rpx;
					background-color: #1a4f8a;
				}
			}
			.teamlist{
				width: 100%;
				box-sizing: border-box;
				padding: 20rpx;
				background-color: white;
				border-radius: 20rpx;
				margin-top: 30rpx;
				 box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.3);
			   .itemteam{
				   width: 100%;
				   height: 90rpx;
				   display: flex;
				   align-items: center;
				   justify-content: space-between;
				   .left{
					   margin-left: 20rpx;
					   .teamname{
						   font-size: 30rpx;
						   font-weight: bold;
					   }
					   .teamtitle{
						   font-size: 26rpx;
						   color: #8E8E8E ;
						   display: flex;
						   align-items: center;
						   .use{
							   font-weight: bold;
							   color: green;
							   margin: 0 10rpx;
						   }
						   .role{
							  font-weight: bold;
							  color: red; 
							   margin: 0 10rpx;
						   }
						   
					   }
				   }
				   .teaminfobox{
				   	display: flex;
				   	align-items: center;
				   	font-size: 28rpx;
				   	
				   	.jujue{
				   		border: 1rpx solid #1a4f8a;
				   		color: #1a4f8a;
				   		border-radius: 10rpx;
				   		background: white;
						width: 100rpx;
						height: 50rpx;
						box-sizing: border-box;
						text-align: center;
						line-height: 50rpx;
				   	}
				   	.tongyi{
				   		border-radius: 10rpx;
				   		color: white;
				   		background: red;
				   		color: white;
				   		margin-left: 20rpx;
						width: 100rpx;
						height: 50rpx;
						box-sizing: border-box;
						text-align: center;
						line-height: 50rpx;
				   	}
				   	
				   }
				   .morebtn{
					   width: 160rpx;
					   height: 70rpx;
					   border: 1rpx solid #1a4f8a;
					   color: #1a4f8a;
					   text-align: center;
					   line-height: 70rpx;
					   border-radius: 20rpx;
					   font-size: 30rpx;
				   }
			   }
				
			}
			
		}
		.getbox{
			width: 100%;
			box-sizing: border-box;
			padding: 20rpx;
			.bannertitle{
				display: flex;
				align-items: center;
				
				padding: 20rpx 30rpx;
				font-size: 36rpx;
				font-weight: bold;
				color: #1a4f8a;
				.iconfont{
					font-size: 50rpx;
					color: #1a4f8a;
					font-weight: bold;
					margin-right: 20rpx;
				}
			}
			.getlist{
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: space-evenly;
				.itemlist{
					width: 47%;
					margin: 1.5%;
					background-color: white;
					 box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.3);
					 box-sizing: border-box;
					 padding: 30rpx;
					 border-radius: 20rpx;
					 height: 300rpx;
					 .itemname{
						 font-size: 34rpx;
						 font-weight: bold;
						 color: #1a4f8a;
					 }
					 .content{
						 color: #5d5d5d;
						 width: 200rpx;
					 }
					 .iconfont{
						 font-size: 80rpx;
						 color: whitesmoke;
						 margin-left: 200rpx;
					 }
				}
			}
		}
		
		
		
		
		
		.foot-tabbar{
			width: 100%;
			height: 150rpx;
			position: fixed;
			left: 0;
			right: 0;
			bottom: 0;
			display: flex;
			align-items: center;
			justify-content: space-evenly;
			background: white;
			overflow: visible;  /* 允许溢出 */
			
			.itemfootbar{
				width: 20%;
				height: 100%;
				text-align: center;
				image{
					width: 60rpx;
					height: 60rpx;
					margin: auto;
				}
				.tabbarname{
					font-size: 26rpx;
					color: #969696;
					font-weight: bold;
				}
				.footact{
					color: #1a4f8a;
				}
				
			}
			.footbardata{
				height: 200rpx !important;
				background: white !important;
				box-sizing: border-box;
				padding-top: 25rpx;
				border-top-right-radius: 75rpx;
				border-top-left-radius: 75rpx;
				
			}
		}
		
	}
</style>
